package com.gitee.swsk33.demoserviceorder.api;

import com.gitee.swsk33.demoentity.dataobject.Order;
import com.gitee.swsk33.demoentity.model.Result;
import com.gitee.swsk33.demoserviceorder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/order")
public class OrderAPI {

	@Autowired
	private OrderService orderService;

	@GetMapping("/get/{id}")
	public Result<Order> get(@PathVariable int id) {
		return orderService.getById(id);
	}

	@GetMapping("/get-by-user/{userId}")
	public Result<List<Order>> getByUser(@PathVariable int userId) {
		return orderService.getByUserId(userId);
	}

}